<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #bt1{
            width: 300px;
            height: 300px;
            background: lightblue;
        }
        #bt2{
            width: 200px;
            height: 200px;
            background: pink;
        }
        #bt3{
            width: 100px;
            height: 100px;
            background: yellow;
        }
    </style>
</head>
<body>
    <div id="bt1">
        <div id="bt2">
            <div id="bt3"></div>
        </div>
    </div>
    <script>
        // 默认冒泡机制
        const bt1=document.getElementById('bt1')
        const bt2=document.getElementById('bt2')
        const bt3=document.getElementById('bt3')
        // DOM0级别事件    attachEvent    addEventListener  DOM2  兼容性问题
        // bt1.onclick=function(event){
        //     console.log(1)
        // }
        // bt2.onclick=function(event){
        //     console.log(2)
        // }
        // bt3.onclick=function(event){
        //     console.log(3)
        // }
        bt3.addEventListener('click',function(event){
            // event.stopPropagation()  阻止冒泡
            // 事件绑定对象 currenttarget
            // 事件触发对象 target
            if(event.target===event.currentTarget){
                console.log(3)
            }
        },true)  // useCapture
        bt2.addEventListener('click',function(event){
            console.log(2)
        },true)  // useCapture
        bt1.addEventListener('click',function(event){
            console.log(1)
        },true)  // useCapture
    </script>
</body>
</html>